home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte22 / ex9.c < prev   
C/C++ Source or Header  |  1995-05-29  |  2KB  |  53 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_COMMAND:
  8.                switch ( LOWORD( wParam ) )
  9.                {
  10.                      case IDM_TEST:
  11.                      {
  12.                            TCHAR szXlatChars[32];
  13.                            TCHAR szBuffer[128];
  14.                            int iBytesNeeded;
  15.                            // Make an ANSI string of characters to translate,
  16.                            static TCHAR szAccentedChars[] = { 0xe1, 0xe2,
  17.                                                              0xe7, 0xe8,
  18.                                                              0xed, 0xec, 0
  19.                                                            };
  20.  
  21.                            // Get space needed
  22.                            iBytesNeeded = FoldString( MAP_COMPOSITE,
  23.                                                       szAccentedChars, -1, 0, 30 );
  24.                            if ( GetLastError() == ERROR_SUCCESS )
  25.                                FoldString( MAP_COMPOSITE, szAccentedChars, -1,
  26.                                            szXlatChars, 30 );
  27.                            else
  28.                            {
  29.                                wsprintf(szBuffer, "Last error: %d", GetLastError());
  30.                                MessageBox( hWnd, szBuffer, "Error", MB_OK );
  31.                            }
  32.  
  33.                            if (GetLastError()==ERROR_SUCCESS) {
  34.                                wsprintf( szBuffer, "Result: %d, Buffer: %s",
  35.                                          iBytesNeeded, szXlatChars );
  36.                                MessageBox( hWnd, szBuffer,
  37.                                            "Fold String Test", MB_OK );
  38.                            }
  39.                      }
  40.                      break;
  41.                      case IDM_EXIT:
  42.                            DestroyWindow( hWnd );
  43.                      break;
  44.                }
  45.                break;
  46.          case WM_DESTROY:
  47.                PostQuitMessage( 0 );
  48.                break;
  49.          default:
  50.                return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
  51.    }
  52.    return( NULL );
  53. }